package Travel_Strategy_14;
import Travel_Strategy_14.TravelWay.*;

public class TravelContext {
    private Bike bike;
    private Car car;
    private Subway subway;

    public void chooseTravelWay(String way, String start, String destination) {
        switch (way) {
            case "bike":
                bike = new Bike();
                bike.travel(start, destination);
                System.out.println("花费时间：15分钟");
                break;
            case "car":
                car = new Car();
                car.travel(start, destination);
                System.out.println("花费时间：5分钟");
                break;
            case "subway":
                subway = new Subway();
                subway.travel(start, destination);
                System.out.println("花费时间：30分钟");
                break;
            default:
                System.out.println("请选择正确的出行方式");
        }
    }
}
